package config
{
	public class DemonConfig
	{
		public static const instance:DemonConfig = new DemonConfig();
		
		private var _xml:XML;
		
		private var _demon:XMLList;
		private var _tower:XMLList;
		private var _bullet:XMLList;
		
		public function DemonConfig()
		{
		}
		
		public function addData( data:String ):void
		{
			_xml = new XML( data );
			_demon = _xml.demons[0].demon;
			_tower = _xml.towers[0].tower;
			_bullet = _xml.bullets[0].bullet;
		}
		
		public function getBulletDataByID( id:int ):XML
		{
			var xl:XMLList = _bullet.(@id==id.toString());
			if( xl.length() > 0 )
			{
				return xl[0];
			}
			return null;
		}
		
		public function getDemonDataByID( id:int ):XML
		{
			var xl:XMLList = _demon.(@id==id.toString());
			if( xl.length() > 0 )
			{
				return xl[0];
			}
			return null;
		}
		
		public function getTowerDataByID( id:int ):XML
		{
			var xl:XMLList = _tower.(@id==id.toString());
			if( xl.length() > 0 )
			{
				return xl[0];
			}
			return null;
		}
	}
}